﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FTBS.Models.DAO;
using FTBS.Models.Entities;
using FTBS.Models.Entities.Concert;

namespace FTBS.Models.BLO
{
    public class ShowTimeBLO
    {
        private ShowTimeDAO _showtimeDao = new ShowTimeDAO();

        /// <summary>
        /// Get SelectList room by theaterId -> This function is used to load selectlist to combobox
        /// </summary>
        /// <param name="theaterId">TheaterId</param>
        /// <returns>List of room</returns>
        /// <author>vuongvt</author>
        public SelectList GetSelectListShowTimeByTheater(int theaterId)
        {
            return _showtimeDao.GetSelectListShowTimeByTheater(theaterId);
        }

        /// <summary>
        /// Get all showtime information
        /// </summary>
        /// <returns></returns>
        public List<ShowTimeConcertEntity> GetAllShowTime()
        {
            return _showtimeDao.GetAllShowTime();
        }

        /// <summary>
        /// Get list showtime by theaterId
        /// </summary>
        /// <param name="theaterId"></param>
        /// <returns></returns>
        public List<ShowTime> GetListShowTimeByTheaterId(int theaterId)
        {
            return _showtimeDao.GetListShowTimeByTheaterId(theaterId);
        }
        public List<ShowTime> GetListShowTimeByFilmId(int filmId) {
            return _showtimeDao.GetListShowTimeByFilmId(filmId);
        }
        /// <summary>
        /// Get a Showtime by ShowTimeId
        /// </summary>
        /// <param name="showtimeId"></param>
        /// <returns></returns>
        public ShowTime GetShowTimeById(int showtimeId)
        {
            return _showtimeDao.GetShowTimeById(showtimeId);
        }

        /// <summary>
        /// Add new ShowTime
        /// </summary>
        /// <param name="showtime"></param>
        /// <returns></returns>
        public int CreateShowTime(ShowTime showtime)
        {
            return _showtimeDao.CreateShowTime(showtime);
        }

        /// <summary>
        /// Delete a showtime
        /// </summary>
        /// <param name="showtime"></param>
        /// <returns></returns>
        public int DeleteShowTime(ShowTime showtime)
        {
            return _showtimeDao.DeleteShowTime(showtime);
        }

        /// <summary>
        /// Edit a showtime
        /// </summary>
        /// <param name="showtime"></param>
        /// <returns></returns>
        public int EditShowTime(ShowTime showtime)
        {
            return _showtimeDao.EditShowTime(showtime);
        }        

        public ShowTime LoadShowTime(int p)
        {
             var showtime = _showtimeDao.GetShowTimeById(p);
             return showtime;
        }

        /// <summary>
        /// Check exist ShowTime when create
        /// </summary>
        /// <param name="showtime"></param>
        /// <returns>True: IsExist -- False: Not Exist</returns>
        /// <author>VuongVT</author>
        public bool IsExistShowTimeCreate(ShowTime showtime)
        {
            return _showtimeDao.IsExistShowTimeCreate(showtime);
        }

        /// <summary>
        /// Check exist ShowTime when Update showtime
        /// </summary>
        /// <param name="showtime"></param>
        /// <returns>True: IsExist -- False: Not Exist</returns>
        /// <author>VuongVT</author>
        public bool IsExistShowTimeUpdate(ShowTime showtime)
        {
            return _showtimeDao.IsExistShowTimeUpdate(showtime);
        }

        
        /// <summary>
        /// Check the ShowTimeId is used in Schedule  and have Booked ticket or not
        /// This function is used for user Click to Edit in List ShowTIme
        /// </summary>
        /// <param name="showTimeId"></param>
        /// <returns>True: Is Exist ---- False: Not Exist</returns>
        /// <author>VuongVT</author>
        public bool IsUserInScheduleAndBooked(int showTimeId)
        {
            return _showtimeDao.IsUserInScheduleAndBooked(showTimeId);
        }

        /// <summary>
        /// Check the ShowTimeId is used in Schedule or not
        /// This function is used for user Click to Delete in List ShowTIme
        /// </summary>
        /// <param name="showTimeId"></param>
        /// <returns>True: Is Exist ---- False: Not Exist</returns>
        /// <author>VuongVT</author>
        public bool IsUsedForSchedule(int showtimeId)
        {
            return _showtimeDao.IsUsedForSchedule(showtimeId);
        }

        ///// <summary>
        ///// Check Date of ShowTime is smaller than Deadline for create or not
        ///// This function is used when staff create ShowTime
        ///// </summary>
        ///// <param name="showtime"></param>
        ///// <returns>True: Smaller --- False: Bigger</returns>
        //public bool IsSmallerThanDeadline(ShowTime showtime)
        //{
        //    return _showtimeDao.IsSmallerThanDeadline(showtime);
        //}

        ///// <summary>
        ///// Check the showtime is comming soon or showing
        ///// </summary>
        ///// <param name="showTimeId"></param>
        ///// <returns>True: Showing -- False: Comming soon</returns>
        ///// <author>VuongVT</author>
        //public bool IsShowingShowTime(Schedule schedule)
        //{
        //    return _showtimeDao.IsShowingShowTime(showTimeId);
        //}
    }
}